<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>系统登录日志</title>
    <script type="text/javascript">
      Ext.onReady(function(){
        //----------------------------------------------------------------------
        var sysLoginLogDS = new Ext.data.Store({
          paramNames: {
            start: "start",
            limit: "limit"
          },
          baseParams: {
            start: 0,
            limit: pageSize
          },
          proxy: new Ext.data.HttpProxy({
            url: '/admin/getAllSysLoginLog'
          }),
          reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
          }, [{
              name: 'id'
            },{
              name: 'employee_id'
            },{
              name: 'company_name',
              mapping:'company',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            },{
              name: 'department_name',
              mapping:'department',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            },{
              name: 'employee_name',
              mapping:'employee',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            }, {
              name: 'name'
            }, {
              name: 'password'
            }, {
              name: 'ip'
            }, {
              name: 'action_date'
            }, {
              name: 'description'
            },{
              name: 'created_at'
            }])
        });
        
        //生成入库Grid的CM
        var sysLoginLogSM = new Ext.grid.CheckboxSelectionModel({singleSelect:true});
        var sysLoginLogCM = new Ext.grid.ColumnModel({defaults: {
            sortable: true,
            menuDisabled: false
          },columns:[new Ext.grid.RowNumberer(),sysLoginLogSM,{
              id: 'common',
              header: 'DB',
              dataIndex: 'id',
              width: 50
            },{
              header: '公司',
              dataIndex: 'company_name',
              width: 150
            },{
              header: '部门',
              dataIndex: 'department_name',
              width: 80
            },{
              header: '员工名称',
              dataIndex: 'employee_name',
              width: 80
            },{
              header: '登录时输入的名称',
              dataIndex: 'name',
              width: 110
            },{
              header: '登录时输入的密码',
              dataIndex: 'password',
              width: 110
            },{
              header: '登录者的IP',
              dataIndex: 'ip',
              width: 110
            },{
              header: '信息',
              dataIndex: 'description',
              width: 100
            },{
              header: '登录时间',
              dataIndex: 'action_date',
              renderer: Ext.util.Format.dateRenderer('Y-m-d H:i'),
              width: 110
            },{
              header: '日期',
              dataIndex: 'created_at',
              renderer: Ext.util.Format.dateRenderer('Y-m-d H:i'),
              width: 110
            }
          ]});

        //生成要订单的产品的Grid
        var sysLoginLogGrid = new Ext.grid.GridPanel({
          title:'系统登录日志列表',
          store: sysLoginLogDS,
          cm: sysLoginLogCM,
          sm: sysLoginLogSM,
          loadMask: true,
          width: screenWidth-170,
          height: screenHeight-565,
          frame: true,
          bbar: new Ext.PagingToolbar({
            pageSize: pageSize,
            store: sysLoginLogDS,
            displayInfo: true,
            displayMsg: "显示第 {0} 条到 {1} 条记录，一共 {2} 条",
            emptyMsg: "没有记录"
          }),
          tbar: [{
              text: '删除',
              iconCls: 'remove',
              handler : function(){
                var record = sysLoginLogSM.getSelected;
                if (!record) {
                  return false;
                }
                sysLoginLogDS.remove(record);
              }
            }]
        });

        sysLoginLogGrid.on('rowdblclick', function(gridPanel, rowIndex, e){
          employeeId = sysLoginLogDS.getAt(rowIndex).get('employee_id');
          actionHxDS.removeAll();
          if (employeeId != null){
            var employeeName = sysLoginLogDS.getAt(rowIndex).get('employee_name');
            //saleOrderDS.reload();          
            actionHxDS.baseParams.employee_id = employeeId;
            actionHxDS.load();
            actionHxGrid.setTitle("用户："+employeeName+"的行为历史记录列表");
          }
        });
        
        sysLoginLogDS.load();


        //------------------------用户操作行为记录----------------------------------------------
        var actionHxDS = new Ext.data.Store({
          paramNames: {
            start: "start",
            limit: "limit"
          },
          baseParams: {
            start: 0,
            limit: pageSize
          },
          proxy: new Ext.data.HttpProxy({
            url: '/admin/getAllActionHxes'
          }),
          reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
          }, [{
              name: 'id'
            },{
              name: 'company_name',
              mapping:'company',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            },{
              name: 'department_name',
              mapping:'department',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            },{
              name: 'role_name',
              mapping:'role',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            },{
              name: 'employee_name',
              mapping:'employee',
              convert:function(value,record){
                if(value == ""){
                  return "";
                }else{
                  return value.name;
                }
              }
            }, {
              name: 'action_params'
            },{
              name: 'created_at'
            }])
        });

        //生成入库Grid的CM
        var actionHxSM = new Ext.grid.CheckboxSelectionModel({singleSelect:true});
        var actionHxCM = new Ext.grid.ColumnModel({defaults: {
            sortable: true,
            menuDisabled: false
          },columns:[new Ext.grid.RowNumberer(),actionHxSM,{
              id: 'common',
              header: 'DB',
              dataIndex: 'id',
              width: 50
            },{
              header: '公司',
              dataIndex: 'company_name',
              width: 150
            },{
              header: '部门',
              dataIndex: 'department_name',
              width: 80
            },{
              header: '员工名称',
              dataIndex: 'employee_name',
              width: 80
            },{
              header: '角色',
              dataIndex: 'role_name',
              width: 80
            },{
              header: '参数',
              dataIndex: 'action_params',
              width: 600
            },{
              header: '操作时间时间',
              dataIndex: 'created_at',
              renderer: Ext.util.Format.dateRenderer('Y-m-d H:i'),
              width: 110
            }
          ]});

        //生成要订单的产品的Grid
        var actionHxGrid = new Ext.grid.GridPanel({
          title:'用户行为历史记录列表',
          store: actionHxDS,
          cm: actionHxCM,
          sm: actionHxSM,
          loadMask: true,
          width: screenWidth-170,
          height: screenHeight-565,
          frame: true,
          bbar: new Ext.PagingToolbar({
            pageSize: pageSize,
            store: actionHxDS,
            displayInfo: true,
            displayMsg: "显示第 {0} 条到 {1} 条记录，一共 {2} 条",
            emptyMsg: "没有记录"
          }),
          tbar: [{
              text: '删除',
              iconCls: 'remove',
              handler : function(){
                var record = actionHxSM.getSelected;
                if (!record) {
                  return false;
                }
                actionHxDS.remove(record);
              }
            }]
        });
        
        //查询
        var name = new Ext.form.TextField({
          fieldLabel: '登录名称',
          name: 'name',
          anchor: '80%'
        });
        
        var searchButton = new Ext.Button({
          text: '搜索',
          iconCls: 'finding',
          width:70,
          handler: function(){
            sysLoginLogDS.removeAll();
            sysLoginLogDS.baseParams.name = name.getValue();
            sysLoginLogDS.load();
          }
        });

        var clearButton = new Ext.Button({
          text: '清空',
          width:50,
          handler: function(){
            queryFormPanel.form.reset();
          }
        });

        var queryFormPanel = new Ext.form.FormPanel({
          //baseCls: 'x-plain',
          //renderTo: 'query_form',
          labelWidth: 60,
          width: screenWidth-175,
          labelAlign: 'right',
          frame : true,
          border:false,
          items: [{
              layout: 'column',
              border: false,
              items: [{
                  columnWidth: .2,
                  layout: 'form',
                  border: false,
                  items: [name]
                }, {
                  columnWidth: .2,
                  layout: 'form',
                  border: false,
                  items: [searchButton]
                }, {
                  columnWidth: .2,
                  layout: 'form',
                  border: false,
                  items: [clearButton]
                }]
            } ]
        });

        //总的panel
        var workbenchPanel = new Ext.Panel({
          width: screenWidth-175,
          height: screenHeight-190,
          //html: '&lt;empty panel&gt;',
          //cls:'cellpadding:10',
          /*layout: {
            type:'vbox',
            align:'stretch'
          },*/
          frame:false,
          layout:'table',
          layoutConfig: {columns:1},
          defaults:{margins:'5 5 5 5'},
          //bodyStyle: 'padding:15px;align:center',
          //listeners: {
          //expand: showAgileDiagram
          //},
          items:[queryFormPanel,sysLoginLogGrid,actionHxGrid]
        });
        workbenchPanel.render("login_log_list_workbench");
        
      })
    </script>
  </head>
  <body>
    <div id="login_log_list_workbench"></div>
  </body>
</html>
